<?php

namespace app\api\controller\applets;

use app\api\model\Car;
use app\api\model\MerchantCar;
use app\common\controller\Api;
use EasyWeChat\Factory;
use fast\Random;
use think\App;
use think\Db;
use think\facade\Validate;
use think\facade\Config;
use app\common\library\Ems;
use app\common\library\Sms;
use think\Request;

/**
 * 门店接口.
 */
class Merchant extends Api
{
    protected $noNeedLogin = ['shopList','shopDetail' , 'shopCarList'];
    protected $noNeedRight = '*';

    protected $model;
    /**
     * 构造方法
     * @access public
     * @param Request $request Request 对象
     */
    public function __construct(Request $request = null)
    {
        parent::__construct(App::getInstance());
        $this->model = new \app\api\model\Merchant();
    }


    public function _initialize()
    {
        parent::_initialize();
        if (!Config::get('fastadmin.usercenter')) {
            $this->error(__('User center already closed'));
        }
    }

    /**
     * 门店列表.
     */
    public function shopList()
    {
        $requestData = $this->request->post();
        $data  = $this->model->shopList($requestData);
        $this->getReturnData($data);
    }
    /**
     * 门店详情.
     */
    public function shopDetail()
    {
        $requestData = $this->request->post();
        $data  = $this->model->shopDetail($requestData);
        $this->getReturnData($data);
    }

    /**
     * 门店详情车辆列表.
     */
    public function shopCarList()
    {
        $requestData = $this->request->post();
        $user = $this->auth->getUserinfo();
        $data  = $this->model->shopCarList($requestData, $user);
        $this->getReturnData($data);
    }
}
